// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

const db = cloud.database();
// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  try {
    const result = await db.collection('block').where({
      user_id: wxContext.OPENID,
    }).get();
    if (result.data[0] != null) {
      return {
        isBlock: result.data[0].block,
      }
    } else
      return {
        msg: "error：user_id不存在",
      }
  } catch (e) {
    console.error(e);
  }

}